public class Recursion01{

	public static void main(String[] args){

		int num = 4;
		AA a1 = new AA();
		//a1.test(num);
		//n = 2
		//n = 3
		//n = 4
		int res = a1.factorial(num);
        System.out.println("res="+res);
        //1*2*3*4= 24
	}
}

class AA{
	public void test(int n){

		if(n > 2){
			test(n - 1);
		}else{
		System.out.println("n="+n);
	    }//n= 2
    }

    //阶乘
    public int factorial(int n){
    	if(n == 1){
    		return 1;
    	}else{
    		return factorial(n - 1) * n;
    	}
    	//24
    }
}
